A two-dimensional (2D) code (for example, a 2D barcode or a quick response (QR) code) can record data symbolically by using a bar and space alternating graph formed by a particular type of geometric graph distributed on a plane (in a 2D direction), according to a particular rule. The 2D code has features such as large information capacity, a wide coding range, strong error tolerance, and high decoding reliability. It is also low cost and easy to produce.
With the development of the Internet and popularization of mobile devices, 2D codes are widely used for various data-related activities. For example, a merchant can post a payment 2D code at a checkout, and a user can scan the payment 2D code by using a 2D code scanning function in an application. Or, in a product promotion, a merchant can post an application-downloadable 2D code in relatively crowded places (such as, a metro or a shopping mall), to attract people passing by to scan the 2D code and to download an associated application. Therefore, merchants or third parties need to provide authentic and valid 2D codes for users, and the users need to be able to effectively verify the 2D codes.